//
//  UserInfo.m
//  Recycling
//
//  Created by jzd on 2018/5/22.
//  Copyright © 2018年 宋佳. All rights reserved.
//

#import "UserInfo.h"
@interface UserInfo ()<NSCoding>

@end
@implementation UserInfo

-(instancetype)setValueDicts:(NSDictionary *)dict{
    if (self == [super init]) {
        [self setValuesForKeysWithDictionary:dict];
    }
    return self;
}
-(void)setValue:(id)value forUndefinedKey:(NSString *)key{
    
}

// 当将一个自定义对象保存到文件的时候就会调用该方法
// 在该方法中说明如何存储自定义对象的属性
// 也就说在该方法中说清楚存储自定义对象的哪些属性

-(void)encodeWithCoder:(NSCoder *)aCoder
{
    [aCoder encodeInt:self.ID forKey:@"ID"];
    [aCoder encodeObject:self.UserName forKey:@"UserName"];
    [aCoder encodeObject:self.LoginName forKey:@"LoginName"];
    [aCoder encodeObject:self.WxName forKey:@"WxName"];
    [aCoder encodeObject:self.WxID forKey:@"WxID"];
    [aCoder encodeObject:self.HeadImg forKey:@"HeadImg"];
    [aCoder encodeObject:self.AreaCode forKey:@"AreaCode"];
    [aCoder encodeObject:self.Role forKey:@"Role"];
    [aCoder encodeObject:self.Token forKey:@"Token"];
    [aCoder encodeObject:self.MD5Pwd forKey:@"MD5Pwd"];
    
}

// 当从文件中读取一个对象的时候就会调用该方法
// 在该方法中说明如何读取保存在文件中的对象
// 也就是说在该方法中说清楚怎么读取文件中的对象
-(id)initWithCoder:(NSCoder *)aDecoder
{
    //注意：在构造方法中需要先初始化父类的方法
    if (self=[super init]) {
        self.ID = [aDecoder decodeIntForKey:@"ID"];
        self.UserName = [aDecoder decodeObjectForKey:@"UserName"];
        self.LoginName = [aDecoder decodeObjectForKey:@"LoginName"];
        self.WxName = [aDecoder decodeObjectForKey:@"WxName"];
        self.WxID = [aDecoder decodeObjectForKey:@"WxID"];
        self.HeadImg = [aDecoder decodeObjectForKey:@"HeadImg"];
        self.AreaCode = [aDecoder decodeObjectForKey:@"AreaCode"];
        self.Role = [aDecoder decodeObjectForKey:@"Role"];
        self.Token = [aDecoder decodeObjectForKey:@"Token"];
        self.MD5Pwd = [aDecoder decodeObjectForKey:@"MD5Pwd"];
    }
    return self;
}
@end
